﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MapgisEbp.QuickDataBase;
using Logistics.DataManage.Local;
using System.Data;
using Logistics.Utils;
using Logistics.DataManage.DAL;

namespace Logistics.DataManage
{
    class OutletsDAO
    {
        public static IDictionary<String, String> GetOutletsNamesBySiteId(String siteId)
        {
            //注：这里的SiteName指的是网点名称(鄙视设计表结构的)
            string sql = "select NetworkID,SiteName from NetworkInfo  where SiteID=?";
            ParameterizedSQL PSQL = LocalDb.Handler.DbAdapter.AdaptSQLAnonymousParams(sql, siteId);
            DataSet ds = LocalDb.Handler.ExecuteQuery(PSQL.SQL, PSQL.Parameters);
            var dict = CollectionUtils.FillDictionary(ds.Tables[0], "NetworkID", "SiteName", false);
            return dict;
        }

        public static string GetOutletsNameById(String Id)
        {
            //注：这里的SiteName指的是网点名称(鄙视设计表结构的)
            string sql = "select SiteName from NetworkInfo  where NetworkID=?";
            ParameterizedSQL PSQL = LocalDb.Handler.DbAdapter.AdaptSQLAnonymousParams(sql, Id);
            Object obj = LocalDb.Handler.ExecuteScalar(PSQL.SQL, PSQL.Parameters);
            return obj==null?"":Convert.ToString(obj);
        }

        //public static OOutlet GetOOutletById(String Id)
        //{
        //    string sql = "select * from NetworkInfo  where NetworkID=?";
        //    ParameterizedSQL PSQL = LocalDb.Handler.DbAdapter.AdaptSQLAnonymousParams(sql, Id);
        //    DataSet ds = LocalDb.Handler.ExecuteQuery(PSQL.SQL, PSQL.Parameters);
        //    if (ds != null && ds.Tables[0].Rows.Count > 0)
        //    {
        //        OOutlet outlet = new OOutlet();
        //        DataRow row = ds.Tables[0].Rows[0];
        //        outlet.SiteID = Convert.ToString(row["SiteID"]);
        //        outlet.Name = Convert.ToString(row["SiteName"]);//注：这里的SiteName指的是网点名称(鄙视设计表结构的)
        //        outlet.NetworkID = Convert.ToString(row["NetworkID"]);
        //        return outlet;
        //    }
        //    return null;
        //}
    }
}
